#{extends 'main.html' /}
#{set title:'Home' /}
<!-- svn test -->
<div id="wrapper" style="margin:auto; width:1024px">
	<div id="navigation"></div>
	<div id="content" class="init-hidden">
		<div id="content-frame">
			<div id="content-title" class="div-title" >homepage</div>
			<div id="content-container" class="div-container">
				<table style="padding:0;margin:0">
					<tr>
						<td style="vertical-align:top;width:710px">
							<div style="width:700px">
								<div id="content-tabs">
									<div id="nav-div">
										<table>
											<tr>
												<td><input type="button" id="welcome-a" name="welcome" class="urlman nav-button" value="Home Page"/></td>
												<td><input type="button" id="friends-a" name="friends" class="urlman nav-button" value="Friends"/></td>
												<td><input type="button" id="groups-a" name="groups" class="urlman nav-button" value="Groups"/></td>
												<td><input type="button" id="posts-a" name="posts" class="urlman nav-button" value="Posts"/></td>
												<td><input type="button" id="info-a" name="info" class="urlman nav-button" value="Info"/></td>
											</tr>
										</table>
									</div>
									<div id="session-user-id" style="display:none"></div>
									<div id="welcome-div"></div>
									<div id="friends-div">								
										<div id="fr-frof-div">
										</div><hr/>
										<div id="fr-nfrof-div">
										</div><hr/>
										<div id="frof-nfr-div">
										</div>
									</div>
									
									<div id="groups-div">								
										<div id="cr-gr-div">
										</div><hr/>
										<div id="fr-nfrof-div">
										</div><hr/>
										<div id="frof-nfr-div">
										</div>
									</div>
									
									<div id="posts-div">									
										<div id="post-create-div">
											<label for="post-create-title">Post title: </label><br/>
											<input type="text" name="post-create-title" value="" id="post-create-title"><br/>
											<label for="post-create-content"></label><br/>
											<textarea name="post-create-content" rows="8" cols="60" id="post-create-content"></textarea><br/>
											<input type="button" name="" value="Submit" id="post-create-submit">	
										</div>
										<hr/>
										<div id="post-disp-div">	
										</div>							
									</div>
									
									<div id="info-div"></div>
								</div>
								<div id="logout"><input type="button" id="logout" value="logout"></div>
							</div>
						</td>
						<td style="text-align:center;vertical-align:top;width:310px">
							<div>
								<div id="portrait-div">
									<div id="portrait-disp-div">
										<img id="thumb" width="200px" src="/public/images/default-user-image" />
									</div>
									<div id="portrait-upload-div" >
									</div>
									<a href="" id="trya" title="aaaa">aaa</a>
								</div>
							</div>
						</td>
					</tr>
				</table>
			</div>			
		</div>
	</div>
	<div id="login" class="init-hidden" onkeydown="doEnter(event)">
		<div id="login-frame">
			<div id="login-title" class="div-title">login</div>
			<div id="login-container" class="div-container">
				<div id="loginerr" class="err-msg init-hidden">Incorrect email or password.</div>
				<label for="email">Email </label><br/>
				<input type="text" name="email" value="" id="email" size="27" class=""><br/>
				<label for="password">Password </label><br/>
				<input type="password" name="password" value="" id="password" size="27" class="">
				<span><input type="submit" value="Login &rarr;" id="submit"></span>
				<span><p> Join Us? </p></span>
			</div>	
		</div>
		
		
	</div>
</div>

<link rel="stylesheet" type="text/css" href="/public/stylesheets/newindex.css"/>
<script type="text/javascript" src="/public/javascripts/newindex.js"></script>
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		$(".urlman").click(function(event) {
			history.pushState({ path: this.path }, '', "?tag="+this.name);
			showContentPart(getParameterByName("tag"));
		})
		
		$(window).bind('popstate', function() {
			showContentPart(getParameterByName("tag"));
		})


		
		showContentPart(getParameterByName("tag"));
		init();
		
		$("#submit").click(function(event) {
			event.preventDefault();
			$.post("/Login/connectJSON", {"u":$("#email").val(), "p":$("#password").val()}, function(result) {
				if(result==false) {
					$("#email").val("").focus();
					$("#password").val("");
					$("#loginerr").show("slow");
					choosePart("login");
				} else {
					updateContent(result);
					choosePart("content");
				}
			}, "json");
		});
		
		$("#logout").click(function() {
			$.post("/Login/logoutJSON", {}, init);
		});
		
		$(":input[type='text'],:input[type='password'],textarea").wijtextbox();
		$(":input[type='button'],:input[type='submit']").button();
		
		
		$("input#post-create-submit").click(function() {
			$.post("/Login/getCurrentUserJSON", {}, function(result) {
				if (result != false) {
					createPost(result);
				} 
			}, "json");
		});
		

		var uploader = new qq.FileUploader({
			element: document.getElementById('portrait-upload-div'),
			action: '/Photos/uploadUserPhoto', 
			allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'], 
			onComplete: function(id, fileName, responseJSON){
				updatePortrait($("#session-user-id").html());
			}
		});
		
		$("[title]").wijtooltip();
		
		
		
	});
</script>